feat(config): resolve relative embedding.model against config dir / source_root#323
Merged
Merged
Conversation
…ource_root A relative `embedding.model` (e.g. `./models/minilm`) was handed to sentence-transformers verbatim and resolved against process CWD — unlike `index_dir` and `source_root`, which anchor on the config file's directory. That made a committed `.java-codebase-rag.yml` non-portable, and could let the CLI indexer and the MCP reader load different models from the same config when their CWDs differed. `maybe_expand_embedding_model_path` now takes optional `config_dir` / `source_root` / `source` kwargs and, after the existing `~` / `$VAR` expansion, resolves a result still `./` / `../`-prefixed to absolute — mirroring `_resolve_index_dir_path`: YAML values anchor on the config file's directory, CLI / env values on `source_root`. Hub ids, absolute paths, `~/`-expanded values, and an env var that already yielded an absolute path are all left untouched. With no base supplied, relative resolution is skipped, so the MCP runtime read (`resolved_sbert_model_for_process_env`) is byte-for-byte unchanged — it receives an already-absolute path from `apply_to_os_environ` in the normal flow. The #239 MCP YAML-loading fix is untouched. Co-Authored-By: Claude <noreply@anthropic.com>
Merged
HumanBean17
added a commit
that referenced
this pull request
Jun 15, 2026
Catch-up: master advanced (#322 installer cross_service_resolution, #323 config embedding.model resolution, #325 version 0.6.2, #326 PR-1 progress.py) while the index-output-rework stack was based on #320. This merges those in so the catch-up PR (#330) carries only PR-2/3/4. Conflicts resolved (both add/add, feature branch is the superset): - java_codebase_rag/progress.py (master had PR-1 state; branch has PR-1 + CallbackRenderer/make_relay/build_index_progress_context) - tests/test_progress.py (master had PR-1's 14 tests; branch adds PR-2/3/4 tests) Auto-merged cleanly: installer.py (#322 + PR-4), pyproject.toml (version 0.6.2 + rich>=14,<15), tests/test_installer.py. Verified: ruff clean; full suite 833 passed, 13 skipped (heavy-gated). Co-Authored-By: Claude <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes
embedding.modelresolve relative paths and environment-variable paths deterministically so a.java-codebase-rag.ymlcan be committed to a real project and work portably across machines and across the CLI indexer vs the MCP reader.A relative
embedding.model(e.g../models/minilm) was previously handed to sentence-transformers verbatim and resolved against process CWD — unlikeindex_dirandsource_root, which already anchor on the config file's directory. That made a committed config non-portable, and could let the CLI indexer and the MCP reader load different models from the same config when their CWDs differed (silent vector-dimension mismatch).Changes
java_codebase_rag/config.py—maybe_expand_embedding_model_pathgains optionalconfig_dir/source_root/sourcekwargs. After the existing~/$VARexpansion, a result still.//../-prefixed is resolved to absolute, mirroring_resolve_index_dir_path:model→ resolves against the config file's directorySBERT_MODEL/--embedding-model→ resolves against the resolvedsource_rootorg/name), absolute paths,~/-expanded values, and an env var that already yielded an absolute path are all left untouched.resolved_sbert_model_for_process_env), relative resolution is skipped → that path is byte-for-byte unchanged. The fix: MCP server loads embedding config from .java-codebase-rag.yml (#238) #239 MCP YAML-loading fix is untouched.tests/test_config.py— 12 new tests (4 integration throughresolve_operator_config, 8 unit on the helper).docs/CONFIGURATION.md— updated theembedding.modelYAML comment block and the Path-expansion table row.User-visible behavior changes
embedding.modelnow loads from a deterministic absolute path (config dir for YAML, source_root for CLI/env) instead of an unreliable CWD.$VAR/${VAR}interpolation (already supported) is preserved.~/....Reindex / env / ontology
embedding.modelthat only worked because CWD lined up, the resolved path now anchors on the config dir. If those differ, run a one-timejava-codebase-rag reprocess --vectors-only. Users with absolute / hub-id /~/$VARmodel values need no reindex.Validation
.venv/bin/ruff check .— all checks passed.venv/bin/python -m pytest tests -q— 788 passed, 11 skipped (env-gated heavy), 0 failurestest_mcp_server_loads_yaml_config_at_startupandtest_mcp_server_yaml_config_precedence_env_over_yamlpass → the fix: MCP server loads embedding config from .java-codebase-rag.yml (#238) #239 MCP fix is intact.No propose/plan doc — bounded, single-file-behavior change.
🤖 Generated with Claude Code